<!DOCTYPE html>
<html>

<head>
    <meta name="layout" content="main2"/>
    <g:set var="entityName" value="${message(code: 'lead.label', default: 'lead')}"/>
    <title>转换商机</title></head>

<body>
<div class="main-body">
    <div class="page-wrapper">
        <div class="page-header">
            <div class="page-header-title">
                <h4>转换商机</h4>
            </div>

            <div class="page-header-breadcrumb">
                <ul class="breadcrumb-title">
                    <li class="breadcrumb-item">
                        <a href="/salesDashboard/index">
                            <i class="icofont icofont-home"></i>
                        </a>
                    </li>
                    <li class="breadcrumb-item">
                        <g:link controller="lead" action="index">转换商机</g:link>
                    </li>
                    <li class="breadcrumb-item">转换商机</li>
                </ul>
            </div>
        </div>

        <div class="page-body">
            <g:if test="${flash.message}">
                <div class="message alert alert-info" role="status">${flash.message}
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                        <span aria-hidden="true">×</span></button>
                </div>
            </g:if>
            <g:hasErrors bean="${this.lead}">
                <ul class="errors" role="alert">
                    <g:eachError bean="${this.lead}" var="error">
                        <li <g:if test="${error in org.springframework.validation.FieldError}">data-field-id="${error.field}"</g:if>>
                            <g:message error="${error}"/></li></g:eachError>
                </ul>
            </g:hasErrors>

            <g:form resource="${this.lead}" action="changeToOpportunitySave" method="POST">
                
                <input type="hidden" name="enableTerritory" id="enableTerritory" value="${this.enableTerritory}"/>
                <input type="hidden" name="id" id="id" value="${this.lead.id}"/>

                <g:if test="${this.enableTerritory}">
                    <div class="card">
                        <div class="card-header">
                            <h5>销售区域</h5>

                            <div class="card-header-right">
                                <i class="icofont icofont-rounded-down"></i>
                            </div>
                        </div>

                        <div class="card-block">
                            <div class="form-group row">
                                <label class="col-md-2 col-form-label is-required">销售区域</label>

                                <div class="col-md-3">
                                    <g:select class="form-control" name="territoryName" optionKey="name" optionValue="name" from="${com.next.Territory.findAllByActive(true)}" noSelection="${['': '请选择']}"/>
                                </div>
                            </div>
                        </div>
                    </div>
                </g:if>

                <div class="card">
                    <div class="card-header">
                        <h5>客户信息</h5>

                        <div class="card-header-right">
                            <i class="icofont icofont-rounded-down"></i>
                        </div>
                    </div>

                    <div class="card-block">

                        <div class="form-group row">
                            <label class="col-md-2 col-form-label is-required">客户名称</label>

                            <div class="col-md-3">
                                <g:textField class="form-control" name="accountName" id="accountName" value="${this.lead?.company}"/>
                            </div>
                            <label class="col-md-2 col-form-label is-required">客户类型</label>

                            <div class="col-md-3">
                                <g:select class="form-control" name="accountType"
                                          id="accountType" optionKey="name" optionValue="name"
                                          from="${com.next.AccountType.list()}"
                                          noSelection="${['': '请选择']}"/>
                            </div>
                        </div>

                        <div class="form-group row">
                            <label class="col-md-2 col-form-label">网站</label>

                            <div class="col-md-3">
                                <g:field type="url" class="form-control" name="website" id="website" value="${this.lead?.website}"/>
                            </div>

                            <label class="col-md-2 col-form-label">上级机构</label>

                            <div class="col-md-3">
                                <g:select class="form-control" name="parent" optionValue="account" optionKey="accountId" from="${com.next.AccountTeam.findAllByUser(this?.user)}" noSelection="${['': '请选择']}" />
                            </div>
                        </div>

                        <div class="form-group row">
                            <label class="col-md-2 col-form-label">行业</label>

                            <div class="col-md-3">
                                <g:select class="form-control" name="industryName" id="industryName" optionValue="name"
                                          optionKey="name"
                                          from="${com.next.Industry.list()}" noSelection="${['': '请选择']}"
                                          value="${this.lead?.industry?.name}"/>
                            </div>

                            <label class="col-md-2 col-form-label">雇员数量</label>

                            <div class="col-md-3">
                                <g:field type="number" class="form-control integer" name="numberOfEmployees" id="numberOfEmployees"
                                         value="${this.lead?.numberOfEmployees}"/>
                            </div>
                        </div>
                    </div>
                </div>
                
                <div class="card">
                    <div class="card-header">
                        <h5>联系人信息</h5>

                        <div class="card-header-right">
                            <i class="icofont icofont-rounded-down"></i>
                        </div>
                    </div>

                    <div class="card-block">
                        <div class="form-group row">
                            <label class="col-md-2 col-form-label is-required">联系人姓名</label>

                            <div class="col-md-3">
                                <g:textField class="form-control" name="contactName" id="contactName"
                                             value="${this.lead?.fullName}"/>
                            </div>

                            <label class="col-md-2 col-form-label">称谓</label>

                            <div class="col-md-3">
                                <g:select class="form-control" name="salutationName" id="salutationName" optionValue="name"
                                          optionKey="name" from="${com.next.Salutation.list()}" noSelection="${['': '请选择']}"
                                          value="${this.lead?.salutation?.name}"/>
                            </div>
                        </div>

                        <div class="form-group row">
                            <label class="col-md-2 col-form-label">手机</label>

                            <div class="col-md-3">
                                <g:textField class="form-control" name="cellphone" id="cellphone"
                                             value="${this.lead?.cellphone}"/>
                            </div>

                            <label class="col-md-2 col-form-label">电话</label>

                            <div class="col-md-3">
                                <g:textField class="form-control" name="phone" id="phone" value="${this.lead?.phone}"/>
                            </div>
                        </div>

                        <div class="form-group row">
                            <label class="col-md-2 col-form-label">头衔</label>

                            <div class="col-md-3">
                                <g:textField class="form-control" name="title" id="title" value="${this.lead?.title}"/>
                            </div>

                            <label class="col-md-2 col-form-label">邮箱</label>

                            <div class="col-md-3">
                                <g:field type="email"  class="form-control" name="email" id="email" value="${this.lead?.email}"/>
                            </div>
                        </div>

                        <div class="form-group row">
                            <div class="col-md-12">
                                <g:submitButton class="btn btn-info" name="update" value="保存"/>
                            </div>
                        </div>

                    </div>
                </div>
            </g:form>
        </div>
    </div>
</div>
</body>
</html>
